package month12;

import java.util.concurrent.*;

public class ThreadPool {
    private static ExecutorService threadPool =
            new ThreadPoolExecutor(4, 8, 1000, TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>(),
            Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        for (int i=0; i<100; i++){
            threadPool.execute(new ThreadTask());
            Thread.sleep(1);
        }

    }

}

class ThreadTask implements Runnable{

    public ThreadTask() {

    }

    public void run() {
        System.out.println(Thread.currentThread().getName());
    }
}